package com.laoxu.java.ms.controller;

import com.laoxu.java.ms.model.User;
import com.laoxu.java.ms.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author laoxu
 * @Date 2022/11/30 20:57
 * @Desc xxx
 */
@RestController
public class UserController {
//    @GetMapping("/user/{id}")
//    public String hello(@PathVariable String id){
//        return "Hello, user"+ id;
//    }
    @Autowired
    UserService userService;

    @GetMapping("/users")
    List<User> getUsers(){
        try {
            Thread.sleep(4000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return userService.getUsers();
    }

    @GetMapping("/user/{id}")
    public User getUserById(@PathVariable Integer id){
        return userService.getUserById(id);
    }

}
